package com.cs342.uwosh.cloudycontacts.tasks.db;

	import java.util.ArrayList;
import java.util.List;

import com.cs342.uwosh.cloudycontacts.Contact;
import com.cs342.uwosh.cloudycontacts.DeleteContactsChooser;
import com.cs342.uwosh.cloudycontacts.MainActivity;
import com.cs342.uwosh.cloudycontacts.R;
import com.cs342.uwosh.cloudycontacts.SqlConnect;


	import android.os.AsyncTask;
import android.widget.ArrayAdapter;

	public class GetAllContactsChooserTask extends AsyncTask<Object, Object, List<Contact>>{

		
		@Override
		protected List<Contact> doInBackground(Object... arg0) {

			SqlConnect db = MainActivity.db;
			
			return db.getAll();
		}
		
		/**
		 * 
		 */
		@Override
		protected void onPostExecute(List<Contact> result)
		{
			ArrayList<Contact> contacts = (ArrayList<Contact>) result;
			
			if (MainActivity.CURRENT_THEME.equals(MainActivity.THEME_DEFAULT))
	        {
				DeleteContactsChooser.deletecontactListAdapter = new ArrayAdapter<Contact>(DeleteContactsChooser.mainContext, R.layout.delete_chooser_list_item_theme_default, R.id.deleteContactItem, contacts);
	        }
	        else if (MainActivity.CURRENT_THEME.equals(MainActivity.THEME_ONE))
	        {
	        	DeleteContactsChooser.deletecontactListAdapter = new ArrayAdapter<Contact>(DeleteContactsChooser.mainContext, R.layout.delete_chooser_list_item_theme1_default, R.id.deleteContactItem, contacts);
	        }
	        else if (MainActivity.CURRENT_THEME.equals(MainActivity.THEME_TWO))
	        {
	        	DeleteContactsChooser.deletecontactListAdapter = new ArrayAdapter<Contact>(DeleteContactsChooser.mainContext, R.layout.delete_chooser_list_item_theme2_default, R.id.deleteContactItem, contacts);
	        }
	        else if (MainActivity.CURRENT_THEME.equals(MainActivity.THEME_THREE))
	        {
	        	DeleteContactsChooser.deletecontactListAdapter = new ArrayAdapter<Contact>(DeleteContactsChooser.mainContext, R.layout.delete_chooser_list_item_theme3_default, R.id.deleteContactItem, contacts);
	        }
			
			
			DeleteContactsChooser.sizeOfAdapter = DeleteContactsChooser.deletecontactListAdapter.getCount();
			DeleteContactsChooser.listOfDeleteContacts.setAdapter(DeleteContactsChooser.deletecontactListAdapter);
		}
	}